<?php
	/*
		PandaForum: PHP Forum Engine
		
		Jesse Gill, 0108377707
	*/
	
	require_once('./src/classes/Page.php');
	
	$page = new Page('ACP');
	
	$page->print_header();
	
	// Only admins can access the admin control panel
	if (! $page->curUser->has_rank("Admin", $page->connection))
		die('You must be an admin to access this page.');
	
	$stats_array = array();
	
	//f
	
	$result = $page->connection->get_result("SELECT * FROM user");
	$stats_array['Number of members:'] = ($result) ? $result->num_rows : 0;
	if ($result)
		$result->free();
	
	$result = $page->connection->get_result("SELECT * FROM category");
	$stats_array['Number of categories:'] = ($result) ? $result->num_rows : 0;
	if ($result)
		$result->free();
	
	$result = $page->connection->get_result("SELECT * FROM forum");
	$stats_array['Number of forums:'] = ($result) ? $result->num_rows : 0;
	if ($result)
		$result->free();
	
	$result = $page->connection->get_result("SELECT * FROM post");
	$stats_array['Number of posts:'] = ($result) ? $result->num_rows : 0;
	if ($result)
		$result->free();
?>
	<link href='src/css/acp.css' rel='stylesheet' type='text/css' />
	<script type="text/javascript" src="src/js/ajax_functions_acp.js"></script>
	
	<h1 class="pageheading">Forum Statistics</h1>
	
	<table>
		<?php
			// Generate the statistics table rows
			foreach ($stats_array as $text => $value)
			{
		?>
				<tr>
					<td><?php echo $text; ?></td>
					<td><?php echo $value; ?></td>
				</tr>
		<?php
			}
		?>
	</table>
<?php
	$page->print_acp_nav();
	$page->print_footer();
?>